package com.conversationboard.view;

import com.conversationboard.config.Configuration;
import com.conversationboard.model.User;

public class ThreadListAdminLinksDisplay {

	public static void includeAdminLinks(StringBuilder buffer, int boardId, int threadId, User currentUser, String mainStyle, String itemStyle) {

		if (!currentUser.isBoardAdmin(boardId)) {
			return;
		}

		buffer.append("<div class='adminlinks'><div class='" + mainStyle + "'>");

		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=deletethread&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Delete</a> ");
		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=undeletethread&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Undelete</a> ");

		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=lockthread&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Lock</a> ");
		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=unlockthread&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Unlock</a> ");

		if (Configuration.getInstance().isShowNotWorksafeLinkForAdmins()) {
			buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=workunsafe&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Work Unsafe</a> ");
			buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=worksafe&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Worksafe</a> ");
		}

		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=deindexthread&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>DeIndex</a> ");
		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=indexthread&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Index</a> ");

		if (currentUser.isSiteAdmin()) {
			buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Admin/AdminEditTitleControllerServlet?boardid=" + boardId + "&amp;threadid=" + threadId + "'>Edit Title</a> ");
		}

		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Admin/AdminMoveThreadToBoardControllerServlet?boardid=" + boardId + "&amp;threadid=" + threadId + "'>Move Thread</a> ");
		buffer.append("<a class='" + itemStyle + "' href='" + Configuration.getInstance().getRoot() + "/Pages/Admin/confirm.jsp?action=dropthreadfromnewposts&amp;boardid=" + boardId + "&amp;threadid=" + threadId + "'>Drop from New Answers</a> ");

		buffer.append("</div></div>");

	}

}
